import 'package:flutter/material.dart';
import 'package:flutter_app/app/models/movie.dart';
import 'package:nylo_framework/nylo_framework.dart';
import 'package:flutter_app/resources/widgets/cover_widget.dart';

class Detail extends StatefulWidget {
  final MoviesList movie;

  const Detail({super.key, required this.movie});

  @override
  createState() => _DetailState();
}

class _DetailState extends NyState<Detail> {
  @override
  get init => () {};

  @override
  Widget view(BuildContext context) {
    return Column(
      crossAxisAlignment: CrossAxisAlignment.start,
      spacing: 10,
      children: [
        Cover(movie: widget.movie),
        Text(
          "剧情简介",
          style: TextStyle(
            fontSize: 14,
            fontWeight: FontWeight.bold,
          ),
        ),
        Text(
          "${widget.movie.vodBlurb ?? ""}",
          style: TextStyle(
            fontSize: 10,
            fontWeight: FontWeight.bold,
          ),
        ),
        SizedBox(height: 10),
        Text(
          "演员",
          style: TextStyle(
            fontSize: 14,
            fontWeight: FontWeight.bold,
          ),
        ),
        // 横向滚动的演员列表
        SizedBox(
          height: 30, // 设置固定高度
          child: widget.movie.vodActor?.isNotEmpty ?? false
              ? ListView.separated(
                  scrollDirection: Axis.horizontal,
                  itemCount: widget.movie.vodActor!.split(",").length,
                  separatorBuilder: (context, index) => SizedBox(width: 8),
                  itemBuilder: (context, index) {
                    final actor =
                        widget.movie.vodActor!.split(",")[index].trim();
                    return Container(
                      padding: EdgeInsets.all(4),
                      decoration: BoxDecoration(
                        color: Colors.black,
                        borderRadius: BorderRadius.all(
                          Radius.circular(8),
                        ),
                      ),
                      child: Center(
                        child: Text(
                          actor,
                          style: TextStyle(
                            fontSize: 12,
                            color: Colors.white,
                          ),
                        ),
                      ),
                    );
                  },
                )
              : Text(
                  "暂无演员信息",
                  style: TextStyle(
                    fontSize: 12,
                    color: Colors.grey,
                  ),
                ),
        ),
        // 添加更多内容...
      ],
    );
  }
}
